package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2023/3/16 9:37
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    @PostMapping("/upload_picture")
    public ResponseResult save(MultipartFile multipartFile){

        return wmMaterialService.upload(multipartFile);
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmMaterialDto materialDto){

        return wmMaterialService.list(materialDto);
    }

    @GetMapping("/del_picture/{id}")
    public ResponseResult deletePicture(@PathVariable("id")Integer materialId){
        return wmMaterialService.deletePicture(materialId);
    }

    @GetMapping("/collect/{id}")
    public ResponseResult collectPicture(@PathVariable("id")Integer materialId){
        return wmMaterialService.collectPicture(materialId);
    }

    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancelCollectPicture(@PathVariable("id")Integer materialId){
        return wmMaterialService.cancelCollectPicture(materialId);
    }
}